/* GSOrderResolveAction.java
 *
 * Project/Product: JZCG-SHBUS
 *
 * Modify Information:
 * =============================================================================
 *   Author	Date       Description
 *   ----------	---------- ---------------------------------------------------
 *   wp	2008-1-23	First release
 *
 * Licensed Materials - Property of APEP
 * =============================================================================
 *    (C) COPYRIGHT Shanghai Auto Mart E-Procurement Co., Ltd. 2007 - 2008
 *    All Rights Reserved.
 *
 *    This software is the confidential and proprietary information of
 *    Shanghai Auto Mart E-Procurement Co., Ltd. ("Confidential Information").
 *    You shall not disclose such Confidential Information and shall use it only
 *    in accordance with the terms of the license agreement you entered into 
 *    with Shanghai Auto Mart E-Procurement Co., Ltd.
 *
 * Noties:
 * =============================================================================
 * 
 */

package com.hitrust.gs.action;

import java.util.ArrayList;
import java.util.HashMap;

import system.LoginContext;

import com.hitrust.gs.bean.GSOperatorBean;
import com.hitrust.gs.bean.GSProviderBean;
import com.hitrust.gs.business.GSManufactureProcessor;
import com.hitrust.gs.business.GSOrderDeptInfoProcessor;
import com.hitrust.gs.business.GSProviderProcessor;
import com.hitrust.gs.business.GSUniteGwProcessor;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.lib.GSSystemConfigurator;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.exception.GSException;

public class GSBusOrderResolveQueryAction extends GSBaseAction {

    /* (non-Javadoc)
     * @see com.hitrust.gs.service.GSBaseAction#execute(com.hitrust.gs.service.GSBaseForm)
     */
    public String execute(GSBaseForm aForm) throws Exception {
        GSManufactureProcessor tGSManufProcessor = new GSManufactureProcessor();
        GSProviderProcessor ppro=new GSProviderProcessor();
        try {
            LoginContext context = (LoginContext) aForm.getSession()
                    .getAttribute(GSBaseConstants.LOGIN);
            // 取得当前操作员可操作企业及下级企业的订货地址
            GSUniteGwProcessor unitePro=new GSUniteGwProcessor();
            ArrayList wareList=unitePro.getWareHouseLevelName(context.getLoginWarehouseCode(), context.getLoginWarehouseCode());
            aForm.getRequest().setAttribute("orderdept", wareList);
            
            //取得订单明细状态
            aForm.getRequest().setAttribute("orderdetailstatuslist", getOrderDetailStatusList());
            
            //取得订单明细状态
            aForm.getRequest().setAttribute("ordertypelist", getOrderTypeList());

            //种类等级
            tGSManufProcessor.getManufactureOfLevel(aForm);
            //根据供应商编号得名称
            GSProviderBean pb=ppro.getProviderById(GSSystemConfigurator.getParam("gs.provider_SW_Id"));
            aForm.getRequest().setAttribute("pname", pb);
        } catch (GSException e) {
            throw e;
        } catch (Exception e) {
            GSLogWriter.error(this, e.getLocalizedMessage());
            throw new GSException("进入产品浏览首页面发生异常");
        }
        return GSBaseConstants.FORWARD_SUCCESS;
    }
    
    /**
     * 取得订单明细状态
     * @return 订单明细状态列表
     */
    private ArrayList getOrderDetailStatusList() {
        ArrayList tResult = new ArrayList();
        
        String [] tArray = new String[2];
        tArray[0] = "3";
        tArray[1] = "复审通过";
        tResult.add(tArray);
        
        tArray = new String[2];
        tArray[0] = "6";
        tArray[1] = "已提交";
        tResult.add(tArray);
        
        tArray = new String[2];
        tArray[0] = "7";
        tArray[1] = "已核准";
        tResult.add(tArray);
        
        tArray = new String[2];
        tArray[0] = "8";
        tArray[1] = "未核准";
        tResult.add(tArray);
        
        tArray = new String[2];
        tArray[0] = "9";
        tArray[1] = "订货中";
        tResult.add(tArray);
        
        tArray = new String[2];
        tArray[0] = "10";
        tArray[1] = "已确认";
        tResult.add(tArray);
        
        tArray = new String[2];
        tArray[0] = "11";
        tArray[1] = "已拒绝";
        tResult.add(tArray);
        
        tArray = new String[2];
        tArray[0] = "12";
        tArray[1] = "交货确认";
        tResult.add(tArray);
        
        tArray = new String[2];
        tArray[0] = "14";
        tArray[1] = "已完成";
        tResult.add(tArray);
        
        tArray = new String[2];
        tArray[0] = "21";
        tArray[1] = "已取消";
        tResult.add(tArray);
        
        tArray = new String[2];
        tArray[0] = "22";
        tArray[1] = "已作废";
        tResult.add(tArray);
                
        return tResult;
    }
    
    private ArrayList getOrderTypeList() {
        ArrayList tResult = new ArrayList();
        String [] tArray = new String[2];
        tArray[0] = "0";
        tArray[1] = "正常采购";
        tResult.add(tArray);
        
        tArray = new String[2];
        tArray[0] = "1";
        tArray[1] = "应急采购";
        tResult.add(tArray);
                
        return tResult;
    }

}
